import { getLevelFirst, getLevelZero, getUserID } from '@/utils';

/** 采购计划Manage数据范围权限判断 */
export const sourceManageTab = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseSourceController/ownCompanyID']) {
    // 公司权限
    return {
      params: 'ownCompanyID',
      ownCompanyID: getLevelZero(),
    };
  } else if (curRes?.['/purchaseSourceController/ownDepartmentID']) {
    return {
      params: 'ownDepartmentID',
      ownDepartmentID: getLevelFirst(),
    };
  } else if (curRes?.['/purchaseSourceController/ownerID']) {
    return {
      params: 'ownerID',
      ownerID: getUserID(),
    };
  }
};

/** 澄清数据列表权限范围 */
export const clarifyTabSwitch = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseSourceClarifyController/applyCompanyID']) {
    // 公司权限
    return {
      params: 'applyCompanyID',
      applyCompanyID: getLevelZero(),
    };
  } else if (curRes?.['/purchaseSourceClarifyController/applyDepartmentID']) {
    return {
      params: 'applyDepartmentID',
      applyDepartmentID: getLevelFirst(),
    };
  } else if (curRes?.['/purchaseSourceClarifyController/applyerID']) {
    return {
      params: 'applyerID',
      applyerID: getUserID(),
    };
  }
};

/** 澄清数据列表权限范围 */
export const expertTabSwitch = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseSourceExpertController/createCompanyID']) {
    // 公司权限
    return {
      params: 'createCompanyID',
      createCompanyID: getLevelZero(),
    };
  } else if (curRes?.['/purchaseSourceExpertController/createDepartmentID']) {
    return {
      params: 'createDepartmentID',
      createDepartmentID: getLevelFirst(),
    };
  } else if (curRes?.['/purchaseSourceExpertController/createrID']) {
    return {
      params: 'createrID',
      createrID: getUserID(),
    };
  }
};

export const supplierTabSwitch = (curRes: Record<string, any>) => {
  if (curRes?.['/supplierInfoController/createCompanyID']) {
    return {
      createCompanyID: getLevelZero(),
      params: 'createCompanyID',
    };
  } else if (curRes?.['/supplierInfoController/createDepartmentID']) {
    return {
      createDepartmentID: getLevelFirst(),
      params: 'createDepartmentID',
    };
  }
  return {};
};

/** 开评标详情1号接口用的switch */
export const supplierOneTabSwitch = (curRes) => {
  if (curRes?.['/purchaseSourceSupplierController/createCompanyID']) {
    // 公司权限
    return {
      params: 'createCompanyID',
      createCompanyID: getLevelZero(),
    };
  } else if (curRes?.['/purchaseSourceSupplierController/createDepartmentID']) {
    return {
      params: 'createDepartmentID',
      createDepartmentID: getLevelFirst(),
    };
  } else if (curRes?.['/purchaseSourceSupplierController/createrID']) {
    return {
      params: 'createrID',
      createrID: getUserID(),
    };
  }
};

/** 开评标详情2号接口用的switch */
export const supplierTwoTabSwitch = (curRes) => {
  if (curRes?.['/purchaseSourcePrepareController/createCompanyID']) {
    // 公司权限
    return {
      params: 'createCompanyID',
      createCompanyID: getLevelZero(),
    };
  } else if (curRes?.['/purchaseSourcePrepareController/createDepartmentID']) {
    return {
      params: 'createDepartmentID',
      createDepartmentID: getLevelFirst(),
    };
  } else if (curRes?.['/purchaseSourcePrepareController/createrID']) {
    return {
      params: 'createrID',
      createrID: getUserID(),
    };
  }
};
/** 采购申请数据范围权限判断 */
export const ApplyManageTab = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseSourceController/ownCompanyID']) {
    return {
      ownCompanyID: getLevelZero(),
      params: 'ownCompanyID',
      // key: 'ownManageTabKey',
    };
  } else if (curRes?.['/purchaseSourceController/ownDepartmentID']) {
    return {
      ownDepartmentID: getLevelFirst(),
      params: 'ownDepartmentID',
      // key: 'ownManageTabKey',
    };
  } else if (curRes?.['/purchaseSourceController/ownerID']) {
    return {
      ownerID: getUserID(),
      params: 'ownerID',
      // key: 'ownManageTabKey',
    };
  } else {
    return {};
  }
};

/**采购人评标代表管理列表接口请求获取*/
export const ExpertManageTabSwitch = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseSourceExpertController/applyCompanyID']) {
    // 公司权限
    return {
      params: 'applyCompanyID',
      applyCompanyID: getLevelZero(),
    };
  } else if (curRes?.['/purchaseSourceExpertController/applyDepartmentID']) {
    return {
      params: 'applyDepartmentID',
      applyDepartmentID: getLevelFirst(),
    };
  } else if (curRes?.['/purchaseSourceExpertController/applyerID']) {
    return {
      params: 'applyerID',
      applyerID: getUserID(),
    };
  }
};

/**专家库数据范围权限*/
export const ExpertsManageCurRes = (curRes) => {
  if (curRes?.['/expertInfoController/createCompanyID']) {
    return {
      createCompanyID: getLevelZero(),
      params: 'createCompanyID',
    };
  } else if (curRes?.['/expertInfoController/createDepartmentID']) {
    return {
      createDepartmentID: getLevelFirst(),
      params: 'createDepartmentID',
    };
  }
};
